package com.example.zingalbumdownloader.adapter;

import java.util.ArrayList;

import com.example.zingalbumdownloader.item.ItemMySong;
import com.example.zingalbumdownloader.model.Song;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class MySongAdapter extends ArrayAdapter<Song> {
	private Context mcontext;
	private ArrayList<Song> arraySongs;

	public MySongAdapter(Context context, int resource, ArrayList<Song> object) {
		super(context, resource, object);
		this.mcontext = context;
		this.arraySongs = object;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View itemSong = convertView;
		if (itemSong == null) {
			itemSong = new ItemMySong(mcontext);
		}

		Song song = arraySongs.get(position);
		if (song != null) {
			TextView titleSong = ((ItemMySong) itemSong).title;
			// TextView namePerformerSong = ((ItemMySong)
			// itemSong).namePerformerSong;

			titleSong.setText((position + 1) + "  " + song.getTitle() + " - "
					+ song.getPerformer());
		}
		return itemSong;
	}
}
